#!/bin/bash
TAG=$1
if [ ! -n "$TAG" ]; then
  echo "请输入镜像版本号"
  exit 1;
fi
IMAGE=harbor.dev.airrnd.com/airedge/airedge-gateway
echo "开始编译代码"
mvn clean package -DskipTests

if [ $? -eq 0 ]; then
		echo "代码编译成功"
else
		echo "代码编译失败"
		exit 1
fi
#cd crd-site-app
echo "开始打包镜像 $IMAGE:$TAG"
docker build -t $IMAGE:$TAG --platform=linux/amd64 . -f ./docker/Dockerfile
if [ $? -eq 0 ]; then
		echo "打包镜像成功: $IMAGE:$TAG"
else
		echo "打包镜像失败: $IMAGE:$TAG"
		exit 1
fi
echo "开始推送镜像 $IMAGE:$TAG"
docker push $IMAGE:$TAG
if [ $? -eq 0 ]; then
		echo "镜像推送成功: $IMAGE:$TAG"
else
		echo "镜像推送失败: $IMAGE:$TAG"
		exit 1
fi